<?php

namespace app\mall\ui\table;

use app\mall\enum\YesNoEnum;
use suframe\thinkAdmin\ui\table\TableInterface;

/**
 * 分类表格
 */
class MallCateTable extends TableInterface
{
    public function header()
    {
        return [
            'id' => ['label' => 'ID', 'sort' => true, 'fixed' => 'left', 'width' => 80],
            'parent_id' => ['label' => '父类'],
            'title' => ['label' => '分类名称'],
            'icon' => ['label' => '图标url', 'type' => 'image'],
            'inx' => ['label' => '排序', 'sort' => true],
            'is_menu_text' => [
                'label' => '菜单',
                'filter' => YesNoEnum::toZhArray(),
                'width' => 100,
                'field' => 'is_menu'
            ],
            'has_child' => ['label' => '子菜单', 'type' => 'link', 'linkConfig' => [
                [
                    'key' => 'has_child',
                    'value' => true,
                    'showValue' => false,
                    'label' => '管理子分类',
                    'icon' => 'fa fa-level-down',
                    'url' => '/mall/admin/mallCate',
                    'vars' => ['id@parent_id']
                ],
            ]],
            'more' => [
                'label' => '更多设置',
                'type' => 'link',
                'width' => 100,
                'linkConfig' => [
                    [
                        'key' => 'has_child',
                        'value' => false,
                        'label' => '属性配置',
                        'url' => '/mall/admin/mallCateAttr/index',
                        'vars' => ['id@cate_id'],
                        'type' => 'dialog',
                        'dialogWidth' => 850,
                        'dialogHeight' => 500,
                    ],
                ]
            ],
        ];
    }

    public function filters()
    {
        return [
            'title' => ['label' => '分类名称', 'type' => 'text'],
        ];
    }
}